package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.dto.DecryptRequest;
import com.tencent.wxcloudrun.dto.StepInfoResponse;
import com.tencent.wxcloudrun.service.WechatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/workInfo")
public class WorkInfoController {

    private final WechatService wechatService;

    @Autowired
    public WorkInfoController(WechatService wechatService) {
        this.wechatService = wechatService;
    }

    @PostMapping("/decryptWalkInfo")
    public ApiResponse decryptWalkInfo(@RequestBody DecryptRequest request) {
        StepInfoResponse stepInfo = wechatService.decryptStepInfo(
            request.getEncryptedData(),
            request.getIv(),
            request.getSessionKey()
        );
        return ApiResponse.ok("解密成功", stepInfo);
    }
} 